import { Group } from '@/types/group'
import { PageResult, PageParam, ApproveReqDto } from '@/types/global'
import { http } from '@/utils/http'

export interface JoinReqDto {
  groupId: number
  memberId: number
}

export const addOrUpdateApi = (data?: Group) => {
  return http.post<Group>('/bk/group/addOrUpdate', data)
}

export const joinApi = (data?: JoinReqDto) => {
  return http.post<Group>('/bk/group/join', data)
}

export const groupProcessApi = (data: ApproveReqDto) => {
  return http.post<Group>('/bk/group/groupProcess', data)
}

export const deleteOrQuiteApi = (data?: JoinReqDto) => {
  return http.post<Group>('/bk/group/delete', data)
}

export const myGroupListApi = (param: PageParam) => {
  return http.get<PageResult<Group>>('/bk/group/myGroupList', param)
}

export const groupListApi = (param: PageParam & { groupId?: number }) => {
  return http.get<PageResult<Group>>('/bk/group/groupList', param)
}

export const getSameGroupApi = (userId: number) => {
  return http.get<Group[]>('/bk/group/getSameGroup', { userId })
}
